package com.sky.mapper;

import com.sky.annotation.AutoFill;
import com.sky.entity.Category;
import com.sky.enumeration.OperationType;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface PaginationMapper {


    List<Category> selectByName(String name, Integer type);

    @AutoFill(OperationType.INSERT)
    void addPagination(Category category);

    @Delete("delete from category where id=#{id}")
    void deleteClassificationById(Long id);

    @AutoFill(OperationType.UPDATE)
    void modifyClassification(Category category);

    @Select("select id, type, name, sort, status, create_time, update_time, create_user, update_user from category where id=#{id}")
    Category getCategoryById(Long id);

    @Select("select id, type, name, sort, status, create_time, update_time, create_user, update_user from category where type=#{type}")
    List<Category> queryByType(Integer type);

    /**
     * 按id选择
     *
     * @param id id
     * @return {@link Category}
     */
    @Select("select id, type, name, sort, status, create_time, update_time, create_user, update_user from category where id =#{id}")
    Category selectById(Long id);
}

